package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.SignalLampHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/4.
 */
@Controller
@RequestMapping("/rds_signalLampHandle")
public class SignalLampHandleController {

    @Resource
    private SignalLampHandleService signalLampHandleService;

    @RequestMapping(value = "/getSignalLampFaultHandle4DT")
    @ResponseBody
    public DTResponseDto getSignalLampFaultHandle4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId, Integer lampMaintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = signalLampHandleService.getSignalLampFaultHandle4DT(dtRequestDto,actorIds, orgId,lampMaintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addLampMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addLampMaintenanceContent(Integer lampFaultId, String lampMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampHandleService.addLampMaintenanceContent(lampFaultId, lampMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishLampMaintenance")
    @ResponseBody
    public JsonMsgDto finishLampMaintenance(String lampMaintenancePhoto,Integer lampMaintainerId,String lampMaintenanceTime,String lampMaintenanceExplain,Integer lampFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampHandleService.finishLampMaintenance(lampMaintenancePhoto,lampMaintainerId,lampMaintenanceTime,lampMaintenanceExplain,lampFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/getLampFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getLampFaultHandleList4App(Integer orgId,Integer maintenanceStatus,String actorIds,Integer count,Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampHandleService.getLampFaultHandleList4App(orgId, maintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getLampReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getLampReceiptInfo4App(Integer lampFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampHandleService.getLampReceiptInfo4App(lampFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }
}
